
from typing import List, Optional
from scorpio.core.providers import LLMClient
from scorpio.core.common import ModelParameter, get_logger

from scorpio.core.common import  EmbeddingConfig
logger = get_logger(__name__)


class ExternalEmbeddingClient:
    def __init__(self, embedding_config: EmbeddingConfig):
        self.model_param = self._to_model_parameter(embedding_config)
        llm_client = LLMClient(provider=self.model_param.provider, 
                            model_param=self.model_param)
        self.client =llm_client.client
    
    def _to_model_parameter(self,embedding_config: EmbeddingConfig) -> ModelParameter:
        return ModelParameter(
            model=embedding_config.model,
            title=embedding_config.model,
            provider=embedding_config.provider,
            base_url=embedding_config.base_url,
            api_key=embedding_config.api_key,
        )
    
    async def get_embedding(self, text: str) -> List[List[float]]:
        response = await self.client.get_embedding(text)
        return response

    